package com.xsmart.oa.api;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.oa.services.ShippingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 周志成
 */
@Controller
@RequestMapping("/api")
public class ShippingController {
    @Autowired
    ShippingService shippingService;

    @RequestMapping(value = "/v1/ShippingService/queryShipping", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryShipping(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.queryShipping(requestBean);
    }

    @RequestMapping(value = "/v1/ShippingService/addShipping", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean addShipping(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.addShipping(requestBean);
    }

    @RequestMapping(value = "/v1/ShippingService/modShipping", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean modShipping(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.modShipping(requestBean);
    }

    @RequestMapping(value = "/v1/ShippingService/delShipping", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean delShipping(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.delShipping(requestBean);
    }

    /**确认该城市是否已存在
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/queryCityIsExist", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryCityIsExist(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.queryCityIsExist(requestBean);
    }



    /**查询运费管理
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/querySeller", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean querySeller(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.querySeller(requestBean);
    }


    /**查询运费模板
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/queryFreightTemplate", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryFreightTemplate(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.queryFreightTemplate(requestBean);
    }

    /**修改配送模板状态
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/modSellerShippingStatus", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean modSellerShippingStatus(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.modSellerShippingStatus(requestBean);
    }

    /**删除
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/delShippingTempletAttr", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean delShippingTempletAttr(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.delShippingTempletAttr(requestBean);
    }



    /**添加运费模板
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/addFrightTemplet", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean addFrightTemplet(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.addFrightTemplet(requestBean);
    }

    /**更新配送模板
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/updateShippingTemplet", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean updateShippingTemplet(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.updateShippingTemplet(requestBean);
    }


    /**查询省市区
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/findParentNode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean findParentNode(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.findParentNode(requestBean);
    }

    /**修改运费模板
     * @param requestBean
     * @param request
     * @return
     */
    @RequestMapping(value = "/v1/ShippingService/modFreightTemplate", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean modFreightTemplate(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return shippingService.modFreightTemplet(requestBean);
    }


}
